
package com.campus.security;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import io.jsonwebtoken.security.Keys;
import java.security.Key;
import java.util.Date;
public class JwtService {
  private static final Key KEY = Keys.hmacShaKeyFor("campus-market-demo-secret-key-should-be-long".getBytes());
  public static String generateToken(String subject, long ttlMillis){
    return Jwts.builder().setSubject(subject)
      .setIssuedAt(new Date())
      .setExpiration(new Date(System.currentTimeMillis()+ttlMillis))
      .signWith(KEY, SignatureAlgorithm.HS256).compact();
  }
}
